package implementor;

import dao.MaterialSpecificationDao;
import dbhandelling.Crude;
import dto.MaterialSpecification;



public class MaterialSpecificationImplementor extends Crude implements MaterialSpecificationDao
{
	String className=new MaterialSpecification().getClass().getName();
	@Override
	public void add(MaterialSpecification mspecs) throws Exception 
	{
		insert(mspecs);
	}

	@Override
	public void update(MaterialSpecification mspecs) throws Exception 
	{
		
		super.update(className, "mCode", mspecs.getmCode(),"autoSpecCode",mspecs.getAutoSpecCode()+"");
		super.update(className, "mSpecs", mspecs.getmSpecs(),"autoSpecCode",mspecs.getAutoSpecCode()+"");
		super.update(className, "status", mspecs.getStatus()+"","autoSpecCode",mspecs.getAutoSpecCode()+"");
		
		
		
	}

	@Override
	public void delete(MaterialSpecification mspecs) throws Exception 
	{
		super.delete(className, "autoSpecCode",mspecs.getAutoSpecCode()+"");
	}

	@Override
	public MaterialSpecification retreive(String conditionField, String ConditionValue) throws Exception 
	{
		MaterialSpecification mspecs=(MaterialSpecification) super.retreive(className,conditionField, ConditionValue);
		return mspecs;
	}

	@Override
	public MaterialSpecification[] retreiveArray(String conditionField, String conditionValue) throws Exception 
	{
		MaterialSpecification[] materialMasters;
		Object[] obj=super.retreiveArrayOnCondition(className, conditionField, conditionValue);
		materialMasters=new MaterialSpecification[obj.length];
		
		for(int i=0;i<materialMasters.length;i++)
		{
			materialMasters[i]=(MaterialSpecification) obj[i];
		}
		
		return materialMasters;
	}

	@Override
	public MaterialSpecification[] retreiveAll() throws Exception 
	{
		MaterialSpecification[] materialMasters;
		
		Object[] obj=super.retreiveAll(className);
		
		materialMasters=new MaterialSpecification[obj.length];
		
		for(int i=0;i<materialMasters.length;i++)
		{
			materialMasters[i]=(MaterialSpecification) obj[i];
		}
		
		return materialMasters;
	}

}
